<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-3-8
 * Time: 上午10:40
 */

namespace api\behaviors;


use common\models\credit_app\Member;
use yii\base\ErrorException;
use yii\filters\AccessControl;

class ChedaiCheck extends AccessControl
{
    public $user = 'chedai_user';

    public function beforeAction($action)
    {
        $uid = \Yii::$app->request->post('uid');
        $token = \Yii::$app->request->post('token');
        if ($uid&&$token){}else{
            throw new ErrorException("post认证参数错误,请检查--token:{$token};uid:{$uid}", 1001);
        }
        $identity = Member::findIdentityByTokenAndUid($token, $uid);
        \Yii::$app->chedai_user->login($identity);
        return parent::beforeAction($action);
    }
}